package com.jeethink.gs.service.impl;

import java.util.List;
import java.util.Map;

import com.jeethink.common.core.domain.AjaxResult;
import com.jeethink.common.core.domain.entity.SysUser;
import com.jeethink.common.utils.DateUtils;
import com.jeethink.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jeethink.gs.mapper.GsCompanyMapper;
import com.jeethink.gs.domain.GsCompany;
import com.jeethink.gs.service.GsCompanyService;
import com.jeethink.common.core.text.Convert;

/**
 * 公司Service业务层处理
 * 
 * @author jeethink
 * @date 2022-08-10
 */
@Service
public class GsCompanyServiceImpl implements GsCompanyService
{
    @Autowired
    private GsCompanyMapper gsCompanyMapper;

    /**
     * 查询公司
     * 
     * @param id 公司ID
     * @return 公司
     */
    @Override
    public GsCompany selectGsCompanyById(String id)
    {
        return gsCompanyMapper.selectGsCompanyById(id);
    }

    /**
     * 查询公司列表
     * 
     * @param gsCompany 公司
     * @return 公司
     */
    @Override
    public List<GsCompany> selectGsCompanyList(GsCompany gsCompany)
    {
        return gsCompanyMapper.selectGsCompanyList(gsCompany);
    }

    /**
     * 新增公司
     * 
     * @param gsCompany 公司
     * @return 结果
     */
    @Override
    public int insertGsCompany(GsCompany gsCompany)
    {
        gsCompany.setCreateTime(DateUtils.getNowDate());
        return gsCompanyMapper.insertGsCompany(gsCompany);
    }

    /**
     * 修改公司
     * 
     * @param gsCompany 公司
     * @return 结果
     */
    @Override
    public int updateGsCompany(GsCompany gsCompany)
    {
        return gsCompanyMapper.updateGsCompany(gsCompany);
    }

    /**
     * 删除公司对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteGsCompanyByIds(String ids)
    {
        return gsCompanyMapper.deleteGsCompanyByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除公司信息
     * 
     * @param id 公司ID
     * @return 结果
     */
    @Override
    public int deleteGsCompanyById(String id)
    {
        return gsCompanyMapper.deleteGsCompanyById(id);
    }

    /**
     * 根据id查询下级公司
     * @author Hyunjin
     * @date 11:47 2022/8/10
     * @return com.jeethink.common.core.domain.AjaxResult
     **/
    @Override
    public List<Map<String,Object>> selectExecutor() {
        SysUser sysUser = ShiroUtils.getSysUser();
        System.out.println(sysUser.getCompanyId());
        //获取当前用户登录公司
        List<Map<String,Object>> selectExecutor=gsCompanyMapper.selectExecutor(sysUser.getCompanyId(),null);
        return selectExecutor;
    }
}
